package com.dgut.demo.controller;

import com.dgut.demo.bean.VipMessage;
import com.dgut.demo.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther 虎
 * @Data 2021/2/4 23:14
 * @Version 1.0
 */
@RestController
public class VipController {
    @Autowired
    private VipService vipService;

    @GetMapping("/getAllVipMessage")
    public List<VipMessage> getAllVipMessage(){
        return vipService.getAllVipMessage();
    }

    @PostMapping("/addOneVipMessage")
    public int addOneVipMessage(String vname,String vphone,String vaddress,double vmoney,String vtype){
        VipMessage vipMessage = new VipMessage();
        vipMessage.setVaddress(vaddress);
        vipMessage.setVmoney(vmoney);
        vipMessage.setVphone(vphone);
        vipMessage.setVtype(vtype);
        vipMessage.setVname(vname);
        return vipService.addOneVipMessage(vipMessage);
    }

    @DeleteMapping("/deleteOneVipMessage")
    public int deleteOneVipMessage(String vid){
        return vipService.deleteOneVipMessage(vid);
    }

    @PutMapping("/updateOneVipMessage")
    public int updateOneVipMessage(String vid,String vname,String vphone,String vaddress){
        VipMessage vipMessage = new VipMessage();
        vipMessage.setVid(vid);
        vipMessage.setVaddress(vaddress);
        vipMessage.setVphone(vphone);
        vipMessage.setVname(vname);
        return vipService.updateOneVipMessage(vipMessage);
    }

    @GetMapping("/getVipMessageById")
    public List<VipMessage> getVipMessageById(String vid){
        return vipService.getVipMessageById(vid);
    }

    @GetMapping("/getVipMessageByName")
    public List<VipMessage> getVipMessageByName(String vname){
        return vipService.getVipMessageByName(vname);
    }

    @GetMapping("/getVipMessageByPhone")
    public List<VipMessage> getVipMessageByPhone(String vphone){
        return vipService.getVipMessageByPhone(vphone);
    }

    @GetMapping("/getVipMessageByAddress")
    public List<VipMessage> getVipMessageByAddress(String vaddress){
        return vipService.getVipMessageByAddress(vaddress);
    }
}
